package com.lianzhihui.romeex.mvp.model;

import android.content.Context;

import com.lianzhihui.romeex.bean.FlowCellBean;
import com.lianzhihui.romeex.net.HttpManager;
import com.lianzhihui.romeex.net.HttpManagerCallback;
import com.lianzhihui.romeex.net.ResultData;
import com.lianzhihui.romeex.utils.FormatUtils;
import com.lianzhihui.romeex.utils.GsonUtil;
import com.lianzhihui.romeex.utils.LogUtil;
import com.lianzhihui.romeex.utils.NumberUtils;
import com.zhouyou.http.exception.ApiException;
import com.zhouyou.http.model.HttpParams;

import java.text.Format;

import static com.lianzhihui.romeex.net.APIConstant.FLOW_CELL_INFO;
import static com.lianzhihui.romeex.net.APIConstant.PLEDGE_UPDATE;

/**
 * Description:
 * Author: RAMON
 * CreateDate: 11/30/20 2:02 PM
 * UpdateUser:
 * UpdateDate:
 * UpdateRemark:
 * Version:
 */
public class UpdateModelImp {

    Context context;
    UpdateInterface callback;

    public UpdateModelImp(Context context, UpdateInterface callback) {
        this.context = context;
        this.callback = callback;
    }

    /**
     * 质押升级
     */
    public void getUpdate(String sum) {

        HttpParams params = new HttpParams();
        params.put("pledgeBalance", FormatUtils.number4Big(sum));
        new HttpManager(context, new HttpManagerCallback() {
            @Override
            public void onSuccess(ResultData o) {
                callback.onUpdate();
            }

            @Override
            public void onError(ApiException e) {
                LogUtil.error("ramon", e.toString());
                callback.onUpdateFail(e.getMessage());
            }
        }).post(PLEDGE_UPDATE, params);

    }

}
